﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;

namespace DataStruct
{
    /// <summary>
    /// 硬盘信息Model
    /// </summary>
    [DataContract]
    public class DiskModel2
    {
        /// <summary>
        /// 硬盘今日写入量
        /// </summary>
        [DataMember]
        public int TodayWritten { get; set; }

        /// <summary>
        /// 硬盘总写入量
        /// </summary>
        [DataMember]
        public int DataWritten { get; set; }

        /// <summary>
        /// 硬盘总读取量
        /// </summary>
        [DataMember]
        public int DataRead { get; set; }

        /// <summary>
        /// 已使用的寿命百分比
        /// </summary>
        [DataMember]
        public int PercentageUse { get; set; }

        /// <summary>
        /// 温度
        /// </summary>
        [DataMember]
        public int Temperature { get; set; }

        /// <summary>
        /// 剩余寿命(单位：%)
        /// </summary>
        public int RemainingLife
        {
            get
            {
                return 100 - PercentageUse;
            }
        }

        /// <summary>
        /// 温度颜色
        /// </summary>
        public SolidColorBrush TemperatureColor
        {
            get
            {
                if (Temperature >= 60)
                {
                    return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ee0000"));
                }
                else if (Temperature >= 55)
                {
                    return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ff0000"));
                }
                else if (Temperature >= 50)
                {
                    return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ff9922"));
                }
                else if (Temperature >= 45)
                {
                    return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ffff00"));
                }
                else
                {
                    return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ffffff"));
                }
            }
        }

        /// <summary>
        /// 硬盘今日写入量颜色
        /// </summary>
        public SolidColorBrush TodayWrittenColor
        {
            get
            {
                if (TodayWritten >= 200)
                {
                    return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ff0000"));
                }
                else if (TodayWritten >= 150)
                {
                    return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ff9922"));
                }
                else if (TodayWritten >= 100)
                {
                    return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ffff00"));
                }
                else if (TodayWritten >= 50)
                {
                    return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ffff66"));
                }
                else
                {
                    return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ffffff"));
                }
            }
        }
    }
}
